//编译
var args = process.argv.splice(2)


var contractName = args[0];
var contractFile = contractName + '.sol';
//console.log(args)

fs = require('fs');
src = fs.readFileSync(contractFile, 'utf8');

var input = {
    language: 'Solidity',
    settings: {
        outputSelection: {
            '*': {
                '*': ['*']
            }
        }
    }
};

// sources: {
//     'HelloWorld.sol': {
//         content: src
//     }
// },

var content = {};
content['content'] = src;
var contractFiles = {};
contractFiles[contractFile] = content;
input['sources'] = contractFiles;

console.log(input);

solc = require('solc');

out = solc.compile(JSON.stringify(input));
outObj = JSON.parse(out);
console.log(outObj);



abi = outObj.contracts[contractFile][contractName].abi;
bytecode = outObj.contracts[contractFile][contractName].evm.bytecode.object;

module.exports = {
    abi: outObj.contracts[contractFile][contractName].abi,
    bytecode: outObj.contracts[contractFile][contractName].evm.bytecode.object
}